﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BuildPlannerLib.SimEvents;
using BuildPlannerLib.Terran.Buildings;

namespace BuildPlannerLib.Terran.SimEvents
{
    // Derived class from Event for Orbital Command energy gain
    public class OCEnergyTick : SimEvent
    {
        // Field for the Command Center
        public IndividualCommandCenter CommandCenter;

        // Constructor with parameters for parent build, Command Center and time
        public OCEnergyTick(Build build, IndividualCommandCenter commandCenter, int time)
        {
            Build = build;
            CommandCenter = commandCenter;
            Time = time;
        }

        // Adds energy, adds event for next energy gain, and adds event for a MULE calldown, if there is enough energy
        public override void Execute()
        {
            CommandCenter.Energy.Change(1);
            if (CommandCenter.Energy.Amount >= 50)
            {
                Build.EventList.Add(new MULECalldown(Build, CommandCenter, TimeConvert.ToInt(Build.CurrentTime)));
            }
            int newTime = TimeConvert.ToInt(Build.CurrentTime) + 444;
            Build.EventList.Add(new OCEnergyTick(Build, CommandCenter, newTime));
        }
    }
}
